package com.yanqu.road.server.cmd.rank;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.rank.UnionActivityRankProto;
import com.yanqu.road.pb.rank.YRankProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.union.GameUnionActivityGroupMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_ACTIVITY_UNION_RANK_LIST, desc = "获取商会跨服活动排行榜数据")
public class CrossUnionActivityRankListCmd extends AbstractCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        UnionActivityRankProto.UnionActivityRankListReqMsg reqMsg = UnionActivityRankProto.UnionActivityRankListReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData(GamePlayer player) {

        YRankProto.YRankReqMsg.Builder builder = YRankProto.YRankReqMsg.newBuilder();
        builder.setActivityId(activityId);
        builder.setGroupId(GameUnionActivityGroupMgr.getGroupId(activityId, player.getUserId()));
        builder.setIdKey(String.valueOf(eGamePlayerEventType.UnionExpRiseRank.getValue()));
        player.sendUnionActivityGroupPacket(CrossProtocol.C2_CROSS_YRANK_GET_UNION_RANK_LIST, builder, activityId);

        /*
        CrossUnionActivityRankDataProto.CrossUnionActivityDataMsg.Builder msg = CrossUnionActivityRankDataProto.CrossUnionActivityDataMsg.newBuilder();
        msg.setActivityId(activityId);
        msg.setUserId(player.getUserId());
        msg.setConditionType(0);
        msg.setRankListType(1);
        player.sendChannelPacket(CrossProtocol.C_CROSS_UNION_ACTIVITY_RANK_LIST, msg);
        */

    }
}
